SELECT t.id FROM c1_role_permission t
WHERE 1 = 1
AND EXISTS (SELECT 1 FROM c1_navigation e WHERE (e.Code = t.`PERMISSION_CODE` OR e.URL = t.`PERMISSION_CODE`) AND e.site_id = :siteId)
AND EXISTS (SELECT 1 FROM c1_permission e WHERE e.id = t.`PERMISSION_ID` AND e.site_id = :siteId)
AND T.ROLE_ID = :roleId
